<template>
  <div class="app-container">
    <eHeader :param-bean="paramBean" :sup_this="sup_this" />
    <eForm ref="form" :sup_this="sup_this" />
    <!--表格渲染-->
    <DataGridTable
      ref="mainTable"
      :sup_this="sup_this"
      :data="data.rtnList"
      :total="total"
      :show-cell-class="true"
      grid-id="reportDefineMngProcessGridId"
      @selection-change="handleGridSelectionChange">
      <DataGridColumnSlot :show-overflow-tooltip="true" prop="funProcessName" label="业务类型" width="150px">
        <template slot-scope="scope">
          <edit :data="scope.row" :sup_this="sup_this" />
        </template>
      </DataGridColumnSlot>
      <DataGridColumnSlot label="操作" width="120px" align="center">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="reportPreview(scope.row)">预览</el-button>
        </template>
      </DataGridColumnSlot>
      <DataGridColumn prop="reportCode" label="编码" width="200px" />
      <DataGridColumn prop="selfStateName" label="状态"/>
      <DataGridColumn prop="reportName" label="名称" />
      <DataGridColumn prop="menuFlag" label="菜单显示" />
      <DataGridColumn prop="reportMenuName" label="菜单名称" />
      <DataGridColumnSlot prop="reportDisplayType" label="报表显示类型">
        <template slot-scope="scope">
          <div v-for="item in dicts.report_display_type" :key="item.id">
            <el-tag v-if="scope.row.reportDisplayType.toString() === item.dictCode" :type="item.attribute1">{{ item.dictName }}</el-tag>
          </div>
        </template>
      </DataGridColumnSlot>
      <DataGridColumnSlot slot="lastUpdateDate" prop="lastUpdateDate" label="更新日期">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateDate) }}</span>
        </template>
      </DataGridColumnSlot>
    </DataGridTable>
    <DynamicLoadReportComp ref="dynamicLoadReportComp" />
  </div>
</template>

<script>
import checkPermission from '@/utils/permission'
import { parseTime } from '@/utils/index'
import eHeader from './module/header'
import edit from './module/edit'
import eForm from './module/form'
import initData from '@/mixins/initData'
import { loadDataUrl } from '@/api/report/reportDefine'
import DynamicLoadReportComp from '@/views/report/reportView/module/DynamicLoadReportComp'

export default {
  components: { DynamicLoadReportComp, eHeader, eForm, edit },
  mixins: [initData],
  // 设置数据字典
  dictTypes: ['report_display_type'],
  props: {
  },
  data() {
    return {
      delLoading: false,
      sup_this: this
    }
  },
  created() {
    this.url = loadDataUrl()
    this.$nextTick(() => {
      this.init()
    })
  },
  mounted() {
  },
  methods: {
    parseTime,
    checkPermission,
    async beforeInit() {
      this.data.rtnList = []
      return true
    },
    reportPreview(row) {
      const _this = this.$refs.dynamicLoadReportComp
      _this.loadComp('report' + row.reportCode, row.reportDisplayType, row.reportName, row.reportCode, row.id, null)
    }
  }
}
</script>
